import Questions.AnswerQuestion;
import org.junit.Before;
import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

import static org.junit.Assert.*;
/**
 * Created by:
 * User: Igor Martynovich and Guzenko Igor
 * Date: 20.11.13
 */
public class TestAnswerQuestion {
    AnswerQuestion question;
    private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
    @Before
    public void initAnswerQuestion(){
      question = new AnswerQuestion("question","answer");
    }
    @Test
    public void testAskQuestion(){
        System.setOut(new PrintStream(outContent));
        question.askQuestion();
        assertEquals("\nquestion",outContent.toString());
    }

    @Test
    public void testIsCorrect(){
        assertTrue("Correct",question.isCorrect("answer"));
    }

    @Test
    public void testIsCorrect1(){
        assertFalse(question.isCorrect("falseAnswer"));
    }

    @Test
    public void testSerialize(){
        String actual  = question.serialize("-");
        String expected = "question-answer";
        assertEquals(expected,actual);
    }
}
